﻿// CheckProjectListCtrl.cpp: 实现文件
//

#include "stdafx.h"
#include "zChecker.h"
#include "CheckProjectListCtrl.h"


// CCheckProjectListCtrl

IMPLEMENT_DYNAMIC(CCheckProjectListCtrl, CListCtrl)

CCheckProjectListCtrl::CCheckProjectListCtrl()
{

}

CCheckProjectListCtrl::~CCheckProjectListCtrl()
{
}


BEGIN_MESSAGE_MAP(CCheckProjectListCtrl, CListCtrl)
	ON_WM_CREATE()
END_MESSAGE_MAP()



// CCheckProjectListCtrl 消息处理程序

void CCheckProjectListCtrl::Populate()
{
	ck::CheckProject* pProject = NULL;
	ck::EnumCheckProject* pProjects = NULL;
	ck::CheckProjectManager* pProjectManager = ck::CheckProjectManager::GetInstance();

	DeleteAllItems();

	pProjects = pProjectManager->GetProjects();
	pProjects->Reset();
	while ((pProject = pProjects->Next()))
	{
		z_uint32 nItem = InsertItem(GetItemCount(), pProject->GetName(), 0);
		SetItemData(nItem, pProject->GetCode());
	}

	pProjects->Release();
}

void CCheckProjectListCtrl::AttachBitmap()
{
	CBitmap bmp;
	if (bmp.LoadBitmap(IDB_BITMAP_CHECK_PROJECT_LIST_32))
	{
		m_il.Create(32, 32, ILC_COLOR32 | ILC_MASK, 0, 0);
		m_il.Add(&bmp, RGB(255, 0, 255));
		int nCount = m_il.GetImageCount();
		for (int i = 1; i < nCount; i++)         //support 16
		{
			m_il.SetOverlayImage(i, i);
		}
		SetImageList(&m_il, TVSIL_NORMAL);
	}
}



int CCheckProjectListCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CListCtrl::OnCreate(lpCreateStruct) == -1)
		return -1;

	// TODO:  在此添加您专用的创建代码

	return 0;
}